#!/bin/bash

DB=rubik
XMLPATH=$(dirname $0)"/../xml"

# Start the server
se_gov

# Cleanup database objects
se_smsd $DB
se_ddb $DB

# Create and run the database
se_cdb $DB
se_sm $DB

# Create the collections
se_term -query "CREATE COLLECTION 'Admin'" $DB
se_term -query "CREATE COLLECTION 'Articles'" $DB
se_term -query "CREATE COLLECTION 'Pages'" $DB

# Load initial documents
se_term -query "LOAD '$XMLPATH/Users.xml' 'Users' 'Admin'" $DB
se_term -query "LOAD '$XMLPATH/Roles.xml' 'Roles' 'Admin'" $DB

# Test results
se_term -query "collection('Admin')" $DB
